$(function(){
    loadHtml();






//修改 
//新增收货地址
	$("#linkbt").click(function(){
		$("#fade").show().height($("body").outerHeight(true));
		$("#light").show();
		var fadeArray = [".deleteornot_btn",".deleteornot_close",".saveaddr_btn"];
		for(j = 0; j < fadeArray.length; j++){
			fadeRmove(fadeArray[j]);
		}
	});


//编辑地址
$(".input_status").attr("disabled",true);
$(".editor").click(function(){
	$(this).parent().siblings("p").children(".input_status").attr("disabled",false);
});

//删除  js
    $(".del_take").click(function(){
    	
    	var Div = $(this).parents(".del_take_div");
    	var personalStatus = $(this).parents(".del_take_div").attr("data_select");
    	if(personalStatus == "false"){
    		Div.attr("data_select","true");
    	}else if(personalStatus == "true"){
    		Div.attr("data_select","false");
    	}
    	
    	
        $("#fade").show().height($("body").outerHeight(true));
		$(".deleteornot").show();
		
		$(".deleteornot_tips").html("您确定要删除选中的商品吗？");
		
        var fadeArray = [".deleteornot_btn",".deleteornot_close"];
		for(j = 0; j < fadeArray.length; j++){
			fadeRmove(fadeArray[j]);
			$(fadeArray[0]).click(function(){
				if($(this).html() == "确定"){
					$(".del_take_div[data_select=true]").remove();
				}else{
					$(".del_take_div[data_select=true]").attr("data_select","false");
				}
			});
			$(fadeArray[1]).click(function(){
				$(".del_take_div[data_select=true]").attr("data_select","false");
			});
		}
    });
//修改



//我的收藏页面


	
	//点击收藏的全选按钮
	$(".category_all").click(function(){
		if($(this).hasClass("radio_icorn_on")){
			$(this).removeClass("radio_icorn_on").addClass("radio_icorn").parents().next().children()
			.children(".category_list").attr("data_select","false").children(".category_list_on").hide();
		}else{
			$(this).removeClass("radio_icorn").addClass("radio_icorn_on").parents().next().children()
			.children(".category_list").attr("data_select","true").children(".category_list_on").show();
		}
	});
	

	function dxCategory(){
		var category_list = $(".category_list");
		for(var i = 0;i < category_list.length; i++){
			$(category_list[i]).click(function(){
				//改变商品状态
				if($(this).children(".category_list_on").is(":visible")){
					$(this).attr("data_select","false").children(".category_list_on").hide();
				}else{
					$(this).attr("data_select","true").children(".category_list_on").show();
				}
				
				//改变全选按钮状态
				if($(".category_list[data_select=true]").length == $(".category_list").length){
					$(this).parent(".category_item").attr("data_all","true").parent().prev().children()
					.children(".category_all").removeClass("radio_icorn").addClass("radio_icorn_on");
				}else{
					$(this).parent(".category_item").attr("data_all","false").parent().prev().children()
					.children(".category_all").removeClass("radio_icorn_on").addClass("radio_icorn");
				}
			});
		}
	}
	
	dxCategory();
	

	$(".category_delete").click(function(){
		//修改
		$("#fade").show().height($("body").outerHeight(true));
		$(".deleteornot").show();
		//修改
		if($(".category_list[data_select=true]").length <= 0){
			$(".deleteornot_tips").html("对不起！您还没有选中任何商品");
		}else{
			$(".deleteornot_tips").html("您确定要删除选中的商品吗？");
		}
		
		var fadeArray = [".deleteornot_btn",".deleteornot_close"];
		for(j = 0; j < fadeArray.length; j++){
			fadeRmove(fadeArray[j]);
			$(fadeArray[0]).click(function(){
				if($(this).html() == "确定"){
					$(".category_list[data_select=true]").remove();
							
					if($(".category_list").length == 0){
						$(".category_all").removeClass("radio_icorn_on").addClass("radio_icorn");
					}
				}
			});
		}
	});
	
	//修改
	function fadeRmove(obj){
		$(obj).click(function(){
			$(".deleteornot").hide();
			$("#fade").hide();
			$("#light").hide();
		});
	}
	//修改
})



//动态登录  js
function switchTab(n){
    for(var i = 1; i <= 2; i++){
        document.getElementById("font_" + i).className = "change_font";
        document.getElementById("tab_con_" + i).style.display = "none";
        document.getElementById("img_" + i).src = "../style/img/radio.png";
    }
    document.getElementById("font_" + n).className = "change";
    document.getElementById("tab_con_" + n).style.display = "block";
    document.getElementById("img_" + n).src = "../style/img/radio_on.png";
}



//我的闲置(交易中、出售中、交易完)  js
function change(n){
    for(var i = 1; i <= 3; i++){
        document.getElementById("sale_" + i).className = "grey";
        document.getElementById("sale_infor_" + i).style.display = "none";
    }
    document.getElementById("sale_" + n).className = "orange";
    document.getElementById("sale_infor_" + n).style.display = "block";
}
//个人中心 tab1  js
function replace(n){
    for(var i = 1; i <= 5; i++){
        document.getElementById("per_" + i).className = "grey";
        document.getElementById("per_infor_" + i).style.display = "none";
    }
    document.getElementById("per_" + n).className = "orange";
    document.getElementById("per_infor_" + n).style.display = "block";
}
//个人中心 tab2  js
function replay(n){
    for(var i = 1; i <= 5; i++){
        document.getElementById("order_" + i).className = "grey";
        document.getElementById("order_infor_" + i).style.display = "none";
    }
    document.getElementById("order_" + n).className = "orange";
    document.getElementById("order_infor_" + n).style.display = "block";
}

// 发布二手（二手房、二手车、其他）  js
function release(n){
    for(var i = 1; i <= 7; i++){
        document.getElementById("rel_" + i).className = "grey";
        document.getElementById("rel_infor_" + i).style.display = "none";
    }
    document.getElementById("rel_" + n).className = "orange";
    document.getElementById("rel_infor_" + n).style.display = "block";
}



function loadHtml(){
    $('#header_div').load('header.html');
    $('#footer_div').load('footer.html');
    $('#page_div').load('pagination.html');
    $('#city_div').load('city_search.html');
}


//page_div   js
//$(document).ready(function() {
//    $("#Pagination").pagination("15");
//});
